package com.zhujy.wy;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class PointNum {

	public static int toDo(int num) {
		if(num == 0)
			return 0;
		double r = Math.sqrt(num);
		String tail = String.valueOf(r);
		int index = tail.indexOf(".");
		String h = tail.substring(0, index);
		String t = tail.substring(index+1,index+2);
		int m = Integer.parseInt(h);
		int p = Integer.parseInt(t);
		int res = 0;
		if(p == 0) {
			res += 4;
		}else {
			m++;
		}
		int i=1,j=m-1;
		while(i<=j) {
			int tmp = (int) (Math.pow(i, 2)+Math.pow(j, 2));
			if(tmp < num) {
				i++;
			}else if(tmp == num) {
				res += i==j?4:8;
				j--;
			}else {
				j--;
			}
		}
		return res;
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int[] arr = new int[50];
		int num = 0;
		while(in.hasNext()) {
			num = in.nextInt();
			int re = toDo(num);
			System.out.println(re);
		}
	}

}
